<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.sinodata.bsm.common.vo.FaultTrapMsg"%>
<%@ include file="../include/taglib.jsp"%>
<%
    response.setHeader("Cache-Control", "no-store");
	response.setHeader("Pragrma", "no-cache");
	response.setDateHeader("Expires", 0);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>指标采集分析页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<%@ include file="../include/common.jsp"%>
<%@ include file="../include/table.jsp"%>
<%@ include file="../include/jbox.jsp"%>

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />

<script type=text/javascript>
    //
	function search(){
		var oTable=$("#propList").dataTable();
		oTable.fnPageChange("first",true);
	}
	
	//执行存储过程
	function doCheck(){
		getTopWin(window).getMessageBox().tip('存储过程执行中,请稍候...', 'loading');
		$.ajax({
			url : '${pageContext.request.contextPath}/selfmainten/bsm!doPropCheckProc.action', 
			type : 'POST',
			dataType : "json",
			success : function(data) {
				if(data.result == '1'){
					getTopWin(window).getMessageBox().tip('存储过程执行成功!', 'success',{timeout: 2000});
					location.reload();
				}else{
					getTopWin(window).getMessageBox().closeTip();
					getTopWin(window).getMessageBox().alert("存储过程执行失败，请查看具体日志信息！","提示");
				}
			}
		});
	}
	
	$(function() {
    	
		var oTable=	$('#propList').dataTable({
			"bProcessing": true, 
			"bServerSide": true, 
			"sServerMethod": 'POST',
			"sAjaxSource":'${pageContext.request.contextPath}/selfmainten/bsm!queryCheckedProp.action',
			"bPaginate": true,
			"bSort": true,
			"bFilter":false,
			"bJQueryUI":false,
			"sPaginationType": "full_numbers",
			"sDom":'rt<"bottom"flpi>',
			"iDisplayLength":15,
			"sScrollX" : '100%',
			"aLengthMenu": [[15, 50], [15, 50]],
			"aoColumns":[
				{"mDataProp":"resid"},
				{"mDataProp":"name"},
				{"mDataProp":"ip"},
				{"mDataProp":"propid"},
				{"mDataProp":"propname"},
				{"mDataProp":"taskid"},
				{"mDataProp":"cycle"},
				{"mDataProp":"date"},
				{"mDataProp":"value"}
			], 
			 "oLanguage": { 
 				"sLengthMenu": "每页 _MENU_ 条",
 				"sZeroRecords": "  ",
				"sInfo": "当前从 _START_ 到 _END_ 条,共 _TOTAL_ 条记录", 
				"sInfoEmpty": "没有找到记录",
				"oPaginate":{"sFirst":"首页","sPrevious":"上一页","sNext":"下一页","sLast":"尾页"}	
			},
		    "fnServerParams":function(aoData){
		    	aoData.push({'name':'resid','value':$('#res_id').val()});
				aoData.push({'name':'ip','value':$('#res_ip').val()});
				aoData.push({'name':'propid','value':$('#prop_id').val()});
				//
				var str=document.getElementsByName("status");
		    	var objarray=str.length;
		    	var status = new Array();
		    	var j = 0;
		    	for (i=0;i<objarray;i++)
		    	{
		    	  if(str[i].checked == true)
		    	  {
		    		  status[j++]=(str[i].value);
		    	  }
		    	}
				aoData.push({'name':'status','value':status});
		    }
		});	
		
	
		$('#res_id').bind('keyup', function(event){
			   if (event.keyCode=="13"){
				   search();
			   }
		});
		
		$('#res_ip').bind('keyup', function(event){
			   if (event.keyCode=="13"){
				   search();
			   }
		});
		
		$('#prop_id').bind('keyup', function(event){
			   if (event.keyCode=="13"){
				   search();
			   }
		});
		
		$('#status').bind('change', function(event){
		    search();
		});
		
		
	});
</script>

</head>
<body style="width:100%;">
	<div class="searchFormStyle" style="width:98%;" >
		 <span class="search-span">
  		    <label >资源ID：</label>
  			<input type="text" id="res_id"/>
    	 </span>
		 <span class="search-span">
  		    <label >过滤IP：</label>
  			<input type="text" id="res_ip"/>
    	 </span>
		 <span class="search-span">
  		    <label>指标起始ID：</label>
  			<input type="text" id="prop_id"/>
    	 </span>
		 <span class="search-span">
  		    <input  type="checkbox" name="status" id="right" value="1" />
   		    <label  for="right">采集成功</label>
            <input  type="checkbox" name="status" id="wrong" value="2" checked="checked"/>
            <label  for="wrong">采集失败</label>
    	 </span>
	    <span class="search-span">
	    	<input type="button" onclick="search();" value="查询" class="searchFormButtonStyle" />
	    </span>
	    <span class="search-span">
	    	<input type="button" onclick="doCheck();" value="执行指标检查" class="searchFormButtonStyle" />
	    </span>
	</div>
	
	<div class="searchFormStyle" style="width:98%;">
	      <span class="search-span">
  		    <label >统计时间：</label>
  		    <span id="time">${time}</span>
    	  </span>
	      <span class="search-span" style="float:right">
  		    <label >提示：自统计时间往前三个采集周期内没有值，被视为采集失败!!</label>
    	 </span>
	</div>
	
	<table id="propList" width="99%"  cellpadding="0" cellspacing="0" border="0" class="display" >
		<thead>
			<tr>
				<th width="3%">资源ID</th>
				<th width="10%">资源名称</th>
				<th width="10%">IP</th>
				<th width="10%">指标ID</th>
				<th width="10%">指标名称</th>
				<th width="6%">任务ID</th>
				<th width="5%">采集周期(S)</th>
				<th width="5%">最后采集时间</th>
				<th width="20%">指标值</th>
			</tr>
		</thead>
	</table>
</body>
</html>